package com.demon.androidbasic.dialog

import android.content.Context
import android.view.View
import android.widget.TextView
import androidx.annotation.StringRes
import com.demon.androidbasic.R
import com.demon.androidbasic.action.AnimAction

/**
 * author : Android 轮子哥
 * github : https://github.com/getActivity/AndroidProject
 * time   : 2018/12/2
 * desc   : 等待加载对话框
 */
class WaitDialog {
    class Builder(context: Context) : BaseDialog.Builder<Builder>(context) {
        private val mMessageView: TextView
        fun setMessage(@StringRes id: Int): Builder {
            return setMessage(getString(id))
        }

        fun setMessage(text: CharSequence?): Builder {
            mMessageView.text = text
            mMessageView.visibility = if (text == null) View.GONE else View.VISIBLE
            return this
        }

        init {
            setContentView(R.layout.wait_dialog)
            setAnimStyle(AnimAction.ANIM_TOAST)
            setBackgroundDimEnabled(false)
            setCancelable(false)
            mMessageView = findViewById(R.id.tv_wait_message)
        }
    }
}